Interactive & Animated Plots
import warnings
import holoviews as hv
import uxarray as ux
warnings.filterwarnings("ignore")
hv.extension("bokeh")
file_dir = "../../meshfiles/"
/home/runner/miniconda3/envs/unstructured-grid-viz-cookbook-dev/lib/python3.10/site-packages/dask/dataframe/_pyarrow_compat.py:17: FutureWarning: Minimal version of pyarrow will soon be increased to 14.0.1. You are using 12.0.1. Please consider upgrading.
warnings.warn(
grid_filename_geoflow = file_dir + "geoflow.grid.nc"
data_filename_geoflow = file_dir + "geoflow.data.nc"
uxds = ux.open_dataset(grid_filename_geoflow, data_filename_geoflow)
v1 = uxds["v1"].nodal_average()
Interactivity
Dynamic Rendering
By setting the “dynamic” parameter to True, the resulting plot will dynamically re-rasterize whenever you zoom.
v1[0][0].plot.rasterize(method="polygon", dynamic=True)
Tools
v1[0][0].plot.polygons().opts(tools=["hover"], width=900, height=400)
v1[0][0].plot.polygons().opts(tools=["hover"], width=900, height=400)
An additional tool that can be selected is the ‘lasso_selecttool, which similar to thebox_select` tool can be used to interactively select points.
v1[0][0].plot.points().opts(tools=["hover", "lasso_select"], width=900, height=400)